package org.finmanager.statistics;

import org.finmanager.core.FinManager;

import javax.swing.*;
import java.util.ArrayList;

/**
 * Created by Kelvin on 27/4/2014.
 */

//A class to manage the statistic function by getting different models and StatisticsUI
public class StatisticsController {
	private final StatisticsModel statisticsModel;
	private final StatisticsUI statisticsUI;

	private ArrayList<JComponent> components = new ArrayList<JComponent>();
	private ArrayList<String> titles = new ArrayList<String>();

	public StatisticsController(FinManager finManager) {
		this.statisticsModel = finManager.getStatisticsModel();
		this.statisticsUI = new StatisticsUI();

		new CategoryPieChartController(this);
		new CategoryStackedBarChartController(this);
		new ItemDistributionController(this);

		statisticsUI.addTab(components, titles);
	}

	public void addComponent(JComponent component, String title) {
		components.add(component);
		titles.add(title);
	}

	public StatisticsModel getStatisticsModel() {
		return statisticsModel;
	}

	public JComponent getUIMainComponent() {
		return statisticsUI.getMainComponent();
	}
}
